package com.wh.trans.controller;

import com.wh.trans.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@Slf4j
@RequestMapping("/trans")
public class TransController {
    @Autowired
    private UserService userService;

    @RequestMapping("/registry")
    @Transactional(rollbackFor = IOException.class,isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
    public String registry(String name, String password) {
        //⽤⼾注册
        userService.insert(name, password);

        return "注册成功";
    }
}
